package com.itheima.ai.task;

import com.itheima.ai.repository.ChatRepository;
import groovy.util.logging.Slf4j;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
@Slf4j
public class ScheduledTask {
    //使用corn表达式每5s执行一次
    @Autowired
    private ChatMemory chatMemory;
    @Autowired
    private ChatRepository ChatRepositoryInMemory;
//    @Scheduled(cron = "0/5 * * * * ?")
//    public void cron() {
////        Set<String> chat = ChatRepositoryInMemory.getChatIds("chat");
////        for (String s : chat) {
////            chatMemory.clear(s);
////            System.out.println("清除历史记录");
////
////
////        }
//
//        chatMemory.clear(  "1742557161672");
//
//    }
}
